
#include "../bulk_storage/bulk_storage.h"
#include "../m_tree/mTree.h"
#include "../metric/xyz.h"
void openMainIndex(const char * main_neigh_base, struct store ** neighStore, struct mTree ** neighTree, size_t neigh_struct_size, 
		   double(*neigh_distance)(const void*,const void*), size_t store_cache_size, size_t tree_cache_size);

int writeBackup(struct store * neigh_store, struct mTree * neigh_tree, const char * atom_base, const char * backup_base, time_t * last_sync, time_t sync_interval);



/**
   A one-function-call-does-all method of indexing many files.  Takes
   the list of files on standard in, and indexes each of them into
   files specified on the command line.  This function uses three
   call-backs and some other information to allow new indexing
   strategies to be implemented very easily.

   @param argc  Argument count

   @param argv Command line arguments.  See usage string for more
   information.  (In source code of file, or pass in argc=0)

   @param constructor See modules->callbacks->neighborhoods->constructor
   @param can_calculate_neighborhood See modules->callbacks->neighborhoods->can calculate
   @param distance See modules->callbacks->metric

   @param neighborhood_size.  The size (in bytes) of a neighborhood struct.  
   @param neighbor_count  The number of neighbors per neighborhood.  (Excludes center amino acid)
   @param radius  The maximum distance between the center and one of it's neighbors.  (In milli-angstroms)

*/
int index_many_neighborhoods(int argc, char * argv[], 
			      void(*constructor)(const char* pdbCode, 
						 void * neigh,
						 struct store * atomStore, 
						 off_t center,
						 off_t neighbors[],
						 short count),
			      int (*can_calculate_neighborhood)(struct store * s, off_t i),
			      double (*distance)(const void * , const void *),
			      size_t neighborhood_size,
			      short neighbor_count,
			      double radius
			      ) ;
			
int queryStructures(int argc, char * argv[],
		    void(*constructor)(const char* pdbCode, 
				       void * neigh,
				       struct store * atomStore, 
				       off_t center,
				       off_t neighbors[],
				       short count),
		    int (*can_calculate_neighborhood)(struct store * s, off_t i),
		    const void*(*print_fcn)(const void *, void *),
		    double (*distance)(const void * , const void *),
		             
		    size_t neighborhood_size,
		    short neighbor_count,
		    double radius,
		    double query_radius
		    ) ;

void buildNeighborhoods(const char * atom_base, 
			struct store * neigh_store, 
			struct mTree * neigh_tree, 

			size_t neighbor_count, 
			double radius, 
			
			void(*constructor)(const char* pdbCode, 
					   void * neigh,
					   struct store * atomStore, 
					   off_t center,
					   off_t neighbors[],
					   short count),
			int (*can_calculate_neighborhood)(struct store * s, off_t i)
			);
			
